package com.happy.unitconvert.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * Swagger配置类
 */
@Configuration
public class SwaggerConfig {

  @Bean
  public OpenAPI customOpenAPI() {
    return new OpenAPI()
        .info(new Info()
            .title("单位转换API服务")
            .description("为Android、iOS、小程序等提供统一的单位转换API服务接口")
            .version("1.0.0")
            .contact(new Contact()
                .name("开发团队")
                .email("dev@happy.com")
                .url("https://www.happy.com"))
            .license(new License()
                .name("Apache 2.0")
                .url("http://www.apache.org/licenses/LICENSE-2.0.html")))
        .servers(List.of(
            new Server().url("http://localhost:8080").description("开发环境"),
            new Server().url("https://api.happy.com").description("生产环境")));
  }
}
